package veterinaria.servlet.cliente;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import veterinaria.excepcion.DAOExcepcion;
import veterinaria.negocio.GestionClientes;

/**
 * Servlet implementation class ClienteModificarServlet
 */
@WebServlet("/ClienteModificarServlet")
public class ClienteModificarServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ClienteModificarServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String x = request.getParameter("idCliente");
		String a = request.getParameter("nombre");
		String b = request.getParameter("apePaterno");
		String c = request.getParameter("apeMaterno");
		String d = request.getParameter("email");
		String e = request.getParameter("direccion");
		String f = request.getParameter("telCasa");
		String g = request.getParameter("telMovil");
		String h = request.getParameter("foto");
		String i = request.getParameter("nota");
		
		
		GestionClientes negocio = new GestionClientes();
		try {
			negocio.actualizar(x,a,b,c,d,e,f,g,h,i);
			response.sendRedirect(request.getContextPath()	+ "/cliente_buscar.jsp");
		} catch (DAOExcepcion y) {
			System.out.println(y.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}
	}

}
